package com.jia.leetCode;

public class Pro5476 {
    public int getWinner(int[] arr, int k) {
        int count = 0;
        int res = arr[0];
        int index = 1;
        while(index < arr.length) {
            if(res > arr[index]) {
                ++count;
            }else {
                count = 1;
                res = arr[index];
            }
            if(k == count) {
                return res;
            }
            ++index;
        }
        return res;
    }

    public static void main(String[] args) {
        Pro5476 pro5476 = new Pro5476();
        int[] arr = {2,1,3,5,4,6,7};
        int k = 2;
        System.out.println(pro5476.getWinner(arr, k));;
    }
}
